<template>
  <div>
    <div>
      <el-row>
        <el-button
          type="primary"
          class="el-icon-arrow-left"
          size="small"
          @click="toback()"
          >返回</el-button
        >
      </el-row>
      <el-tabs type="border-card">
        <el-tab-pane label="基本信息">
          <div>
            <el-descriptions class="margin-top" :column="3" border>
              <template slot="extra">
                <el-button type="primary" size="small" @click="updateEp()"
                  >修改</el-button
                >
              </template>
              <el-descriptions-item>
                <template slot="label"> 企业名称 </template>
                {{ epdata.epname }}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 社会信用代码 </template>
                {{ epdata.epcode }}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 行业类型 </template>
                {{ epdata.epitype }}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 企业成立时间 </template>
                {{ epdata.epetime }}
              </el-descriptions-item>
              <el-descriptions-item label="注册资金">
                {{ epdata.epcapital }}</el-descriptions-item
              >
              <el-descriptions-item label="企业类型">{{
                epdata.eptype
              }}</el-descriptions-item>
              <el-descriptions-item :span="3">
                <template slot="label"> 企业注册地址 </template>
                {{ epdata.epaddress }}
              </el-descriptions-item>
              <el-descriptions-item label="营业执照号">{{
                epdata.epblnumber
              }}</el-descriptions-item>

              <el-descriptions-item label="员工人数">{{
                epdata.epempnumber
              }}</el-descriptions-item>
            </el-descriptions>
          </div>

          <!-- 模态框 -->
          <div>
            <el-dialog
              title="企业基本信息修改"
              :visible.sync="dialogFormVisible"
            >
              <el-form :model="epform">
                <el-form-item label="企业名称" :label-width="formLabelWidth">
                  <el-input
                    v-model="epform.epname"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="行业类型" :label-width="formLabelWidth">
                  <el-input
                    v-model="epform.epitype"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="企业类型" :label-width="formLabelWidth">
                  <el-input
                    v-model="epform.eptype"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="员工人数" :label-width="formLabelWidth">
                  <el-input
                    v-model="epform.epempnumber"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item
                  label="企业注册地址"
                  :label-width="formLabelWidth"
                >
                  <el-input
                    v-model="epform.epaddress"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisible = false">取 消</el-button>
                <el-button type="primary" @click="updateEpdata()"
                  >确 定</el-button
                >
              </div>
            </el-dialog>
          </div>

          <div>
            <div>
              <el-divider><i class="el-icon-user" /></el-divider>
            </div>
            <div>
              <el-descriptions
                class="margin-top"
                title="法人信息"
                :column="3"
                border
              >
                <template slot="extra">
                  <el-button type="primary" size="small" @click="updatelp()"
                    >修改</el-button
                  >
                </template>
                <el-descriptions-item>
                  <template slot="label"> 法人姓名 </template>
                  {{ epdata.lpid.lpname }}
                </el-descriptions-item>
                <el-descriptions-item>
                  <template slot="label"> 性别 </template>
                  {{ epdata.lpid.lpgender }}
                </el-descriptions-item>
                <el-descriptions-item>
                  <template slot="label"> 证件类型 </template>
                  {{ epdata.lpid.lpdtype }}
                </el-descriptions-item>
                <el-descriptions-item>
                  <template slot="label"> 证件号 </template>
                  {{ epdata.lpid.lpdnumber }}
                </el-descriptions-item>
                <el-descriptions-item label="手机号">
                  {{ epdata.lpid.lpphonenumber }}</el-descriptions-item
                >
                <el-descriptions-item label="邮箱号">{{
                  epdata.lpid.lpemile
                }}</el-descriptions-item>
              </el-descriptions>
            </div>
          </div>

          <!-- 模态框 -->
          <div>
            <el-dialog
              title="法人基本信息修改"
              :visible.sync="dialogFormVisibleLp"
            >
              <el-form :model="lpform">
                <el-form-item label="法人姓名" :label-width="formLabelWidth">
                  <el-input
                    v-model="lpform.lpname"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="性别" :label-width="formLabelWidth">
                  <el-input
                    v-model="lpform.lpgender"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="证件类型" :label-width="formLabelWidth">
                  <el-input
                    v-model="lpform.lpdtype"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="证件号" :label-width="formLabelWidth">
                  <el-input
                    v-model="lpform.lpdnumber"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="手机号" :label-width="formLabelWidth">
                  <el-input
                    v-model="lpform.lpphonenumber"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="邮箱号" :label-width="formLabelWidth">
                  <el-input
                    v-model="lpform.lpemile"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisibleLp = false"
                  >取 消</el-button
                >
                <el-button type="primary" @click="updatelpdata()"
                  >确 定</el-button
                >
              </div>
            </el-dialog>
          </div>

          <div>
            <div>
              <el-divider><i class="el-icon-user-solid" /></el-divider>
            </div>
            <div>
              <div>
                <el-descriptions
                  class="margin-top"
                  direction="vertical"
                  title="企业联系人信息"
                  :column="4"
                  border
                >
                  <template slot="extra">
                    <el-button type="primary" size="small" @click="updateecc()"
                      >修改</el-button
                    >
                  </template>
                  <el-descriptions-item>
                    <template slot="label"> 姓名 </template>
                    {{ epdata.eccid.ecname }}
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label"> 职务 </template>
                    {{ epdata.eccid.ecpost }}
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label"> 联系电话 </template>
                    {{ epdata.eccid.ecphone }}
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label"> 电子邮箱 </template>
                    {{ epdata.eccid.ecemile }}
                  </el-descriptions-item>
                </el-descriptions>
              </div>
            </div>
          </div>

          <!-- 模态框 -->
          <div>
            <el-dialog
              title="企业联系人信息修改"
              :visible.sync="dialogFormVisibleEcc"
            >
              <el-form :model="eccform">
                <el-form-item
                  label="企业联系人姓名"
                  :label-width="formLabelWidth"
                >
                  <el-input
                    v-model="eccform.ecname"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="职务" :label-width="formLabelWidth">
                  <el-input
                    v-model="eccform.ecpost"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="联系电话" :label-width="formLabelWidth">
                  <el-input
                    v-model="eccform.ecphone"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="电子邮箱" :label-width="formLabelWidth">
                  <el-input
                    v-model="eccform.ecemile"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisibleEcc = false"
                  >取 消</el-button
                >
                <el-button type="primary" @click="updateEccdata()"
                  >确 定</el-button
                >
              </div>
            </el-dialog>
          </div>
        </el-tab-pane>
        <el-tab-pane label="资产负债表">资产负债表</el-tab-pane>
        <el-tab-pane label="利润表">利润表</el-tab-pane>
        <el-tab-pane label="定时任务补偿">定时任务补偿</el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
     
      dialogFormVisible: false,
      dialogFormVisibleLp: false,
      dialogFormVisibleEcc: false,
      formLabelWidth: "120px",
      ep: [],
      epdata: {
        epid: 0,
        epname: "", //企业名称
        epcode: "", //社会信用代码
        epitype: "", //行业类型
        epetime: "", //企业成立时间
        epcapital: 0, //注册资金
        epblnumber: "", //营业执照号
        eptype: "", //企业类型
        epempnumber: 0, //员工人数
        epaddress: "", //企业注册地址
        lpid: {
          // 法人
          lpid: 0,
          lpname: "", //法人姓名
          lpgender: "", //性别
          lpdtype: "", //证件类型
          lpdnumber: "", //证件号
          lpphonenumber: "", //手机号
          lpemile: "", //邮箱号
        },
        eccid: {
          //联系方式
          eccid: 0,
          ecname: "", //企业联系人姓名
          ecpost: "", //职务
          ecphone: "", //联系电话
          ecemile: "", //电子邮箱
        },
        epstate: 0, //黑名单状态 1-是，0-否（默认）
      },
      epform: {
        epid: 0,
        epname: "", //企业名称
        epcode: "", //社会信用代码
        epitype: "", //行业类型
        epetime: "", //企业成立时间
        epcapital: 0, //注册资金
        epblnumber: "", //营业执照号
        eptype: "", //企业类型
        epempnumber: 0, //员工人数
        epaddress: "", //企业注册地址
      },

      lpform: {
        lpid: 0,
        lpname: "", //法人姓名
        lpgender: "", //性别
        lpdtype: "", //证件类型
        lpdnumber: "", //证件号
        lpphonenumber: "", //手机号
        lpemile: "", //邮箱号
      },

      eccform: {
        eccid: 0,
        ecname: "", //企业联系人姓名
        ecpost: "", //职务
        ecphone: "", //联系电话
        ecemile: "", //电子邮箱
      },
    };
  },
  created() {
    let epid = this.$route.query.epid;
    console.log(epid);
    this.init(epid);
  },
  methods: {
    toback() {
      //跳转页面
      this.$router.push("/epinfo");
    },

    init(epid) {
      this.$axios
        .get("http://localhost:8082/enp/epbyid/" + epid)
        .then((resp) => {
          console.log(resp);
          this.ep = resp.data.data;
          this.lpform = resp.data.data.lpid;
          this.epdata = resp.data.data;
        });
    },

    updateEp() {
      this.dialogFormVisible = true;
      this.epform = { ...this.ep };
    },
    updateEpdata() {
      this.$axios
        .put("http://localhost:8082/enp/updateEp", this.epform)
        .then((r) => {
          console.log("修改成功");
          this.dialogFormVisible = false;
          this.init(this.epdata.epid);
          this.$message({
            message: "修改成功",
            type: "success",
          });
        });
    },

    updatelp() {
      this.dialogFormVisibleLp = true;
      this.lpform = { ...this.ep.lpid };
    },

    updatelpdata() {
      this.$axios
        .put("http://localhost:8082/enp/updateLp", this.lpform)
        .then((r) => {
          console.log("修改成功");
          this.dialogFormVisibleLp = false;
          this.init(this.epdata.epid);
          this.$message({
            message: "修改成功",
            type: "success",
          });
        });
    },

    updateecc() {
      this.dialogFormVisibleEcc = true;
      this.eccform = { ...this.ep.eccid };
    },
    updateEccdata() {
      this.$axios
        .put("http://localhost:8082/enp/updateEcc", this.eccform)
        .then((r) => {
          console.log("修改成功");
          this.dialogFormVisibleEcc = false;
          this.init(this.epdata.epid);
          this.$message({
            message: "修改成功",
            type: "success",
          });
        });
    },

    
  },
};
</script>

<style>
</style>